package com.emergency.embackend.service.impl;

import com.emergency.embackend.entity.Quiz;
import com.emergency.embackend.mapper.TestFirstMapper;
import com.emergency.embackend.service.TestFirstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TestFirstServiceImpl implements TestFirstService {
    @Autowired
    private TestFirstMapper testFirstMapper;
    @Override
    public Map<Integer, List<Quiz>> getByTypeId(List<Integer> typeIds) {
        Map<Integer, List<Quiz>> resultMap = new HashMap<>();
        for (Integer typeId : typeIds) {
            List<Quiz> dataList = testFirstMapper.selectRandomByQuizTypeId(typeId, 2); // 使用实例调用方法，并限制返回2条数据
            resultMap.put(typeId, dataList);
        }
        return resultMap;
    }
}